<?php
	include("../include/config.php");
	include("../include/functions.php");
	
	if($_GET['table']){
		mysqli_query($db_connect, "DELETE FROM `on_projects` WHERE id='$_GET[page_id]'");
	
		header('location:../index.php?data=projects');
	}
	if(isset($_POST['id']) && $_POST['id']==''){
			$_POST['created_date']=date("Y-m-d H:i:s");						$_POST['updated_date']=date("Y-m-d H:i:s");						if($_FILES['image']['name']){				 $image_file=rand().$_FILES['image']['name'];				$image_path='../../img/'.$image_file;				$temp=$_FILES['image']['tmp_name'];				copy($temp,$image_path);				$_POST['image']=$image_file;			}else{			$_POST['image']='';			}			if($_FILES['route_map']['name']){				 $image_file=rand().$_FILES['route_map']['name'];				$image_path='../../maps/'.$image_file;				$temp=$_FILES['route_map']['tmp_name'];				copy($temp,$image_path);				$_POST['route_map']=$image_file;			}else{			$_POST['route_map']='';			}			if($_FILES['layout_map']['name']){				 $image_file=rand().$_FILES['layout_map']['name'];				$image_path='../../maps/'.$image_file;				$temp=$_FILES['layout_map']['tmp_name'];				copy($temp,$image_path);				$_POST['layout_map']=$image_file;			}else{			$_POST['layout_map']='';			}						db_insert('on_projects',$_POST);
			
			header('location:../index.php?data=projects');
			
	}else{			$_POST['updated_date']=date("Y-m-d H:i:s");
				$product_id=array_shift($_POST);						if($_FILES['resume']['name']){					 $image_file=rand().$_FILES['resume']['name'];					$image_path='../../img/'.$image_file;					$temp=$_FILES['resume']['tmp_name'];					copy($temp,$image_path);					$_POST['resume']=$image_file;				}				if($_FILES['route_map']['name']){					 $image_file=rand().$_FILES['route_map']['name'];					$image_path='../../maps/'.$image_file;					$temp=$_FILES['route_map']['tmp_name'];					copy($temp,$image_path);					$_POST['route_map']=$image_file;				}				if($_FILES['layout_map']['name']){					 $image_file=rand().$_FILES['layout_map']['name'];					$image_path='../../maps/'.$image_file;					$temp=$_FILES['layout_map']['tmp_name'];					copy($temp,$image_path);					$_POST['layout_map']=$image_file;				}			db_update('on_projects',$_POST,array('id'=>$product_id));
			
			header('location:../index.php?data=projects');
	}
	
?>